package com.yunshipei.ui.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;

import com.yunshipei.common.Globals;
import com.yunshipei.common.manager.EnterConfig;
import com.yunshipei.core.utils.CommonUtils;
import com.yunshipei.manager.YspPreferences;

public class BaseNavItemFragment extends Fragment {

    protected String mProxyIP = "";
    protected int mProxyPort = 0;
    protected String[] mExclusionList;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SharedPreferences preferences = getActivity().getSharedPreferences(Globals.NO_CLEAR_SHP, Context.MODE_PRIVATE);
        SharedPreferences yspPreferences = YspPreferences.getInstance().getSharedPreferences();
        String proxy = preferences.getString(Globals.MANUAL_PROXY, "");
        int port = preferences.getInt(Globals.MANUAL_PROXY_PORT, 0);
        if (TextUtils.isEmpty(proxy) || port == 0) {
            proxy = yspPreferences.getString(Globals.SP_HUB_GET_PROXY_IP, "");
            port = yspPreferences.getInt(Globals.SP_HUB_GET_PROXY_PORT, 0);
        }
        if (!TextUtils.isEmpty(proxy) && port != 0) {
            mProxyIP = proxy;
            mProxyPort = port;
            String host = CommonUtils.getHost(EnterConfig.getInstance().getManagerServer());
            mExclusionList = new String[]{host};
        }
    }
}
